/*
 Copyright (C) 2008  Maurizio Monticelli

 This program is free software; you can redistribute it and/or modify it under the terms of the 
 GNU General Public License as published by the Free Software Foundation; either version 2 of the 
 License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
 even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 
 Public License for more details.

 You should have received a copy of the GNU General Public License along with this program; if not, write 
 to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 
*/

package ch.justdoit.andriodrpncalc.view;

import android.content.Context;
import ch.justdoit.R;
import android.widget.AbsoluteLayout;
import ch.justdoit.andriodrpncalc.model.Model;
import ch.justdoit.andriodrpncalc.view.buttons.*;

public class KeyNumbers extends AbsoluteLayout{
	private Model model;
	
	public static int WIDTH = 90;
	public static int HEIGHT = 120;
	
	public KeyNumbers(Context context,  Model _model) {
		super(context);
		model = _model;
		//setBackgroundColor(0xff584862);
	
		
        int x = 0;
        int y = 0;

        ButtonKeyAlpha btn7 = new ButtonKeyAlpha(context, model);
        btn7.registerAlphaFunction(R.drawable.keyx7, "x");
        btn7.registerFirstFunction(R.drawable.key7x, "7");
		model.mView.registerAlphaButton(btn7);
		addView(btn7, 
    			new AbsoluteLayout.LayoutParams(btn7.WIDTH, btn7.HEIGHT, x , y)
    	);
		x = x + btn7.WIDTH;

		ButtonKeyAlpha btn8 = new ButtonKeyAlpha(context, model);
		btn8.registerAlphaFunction(R.drawable.keyy8, "y");
		btn8.registerFirstFunction(R.drawable.key8y, "8");
		model.mView.registerAlphaButton(btn8);
		addView(btn8, 
    			new AbsoluteLayout.LayoutParams(btn8.WIDTH, btn8.HEIGHT, x , y)
    	);
		x = x + btn8.WIDTH;

		ButtonKeyAlpha btn9 = new ButtonKeyAlpha(context, model);
		btn9.registerAlphaFunction(R.drawable.keyz9, "z");
		btn9.registerFirstFunction(R.drawable.key9z, "9");
		model.mView.registerAlphaButton(btn9);
		addView(btn9, 
    			new AbsoluteLayout.LayoutParams(btn9.WIDTH, btn9.HEIGHT, x , y)
    	);
		y = y + btn9.HEIGHT;
		
		x = 0;
		ButtonKeyAlpha btn4 = new ButtonKeyAlpha(context, model);
		btn4.registerAlphaFunction(R.drawable.keyd4, "d");
		btn4.registerFirstFunction(R.drawable.key4d, "4");
		model.mView.registerAlphaButton(btn4);
		addView(btn4, 
    			new AbsoluteLayout.LayoutParams(btn4.WIDTH, btn4.HEIGHT, x, y)
    	);
		x = x + btn4.WIDTH;

		ButtonKeyAlpha btn5 = new ButtonKeyAlpha(context, model);
		btn5.registerAlphaFunction(R.drawable.keyf6, "e");
		btn5.registerFirstFunction(R.drawable.key5f, "5");
		model.mView.registerAlphaButton(btn5);
		addView(btn5, 
    			new AbsoluteLayout.LayoutParams(btn5.WIDTH, btn5.HEIGHT, x , y)
    	);
		x = x + btn5.WIDTH;

		ButtonKeyAlpha btn6 = new ButtonKeyAlpha(context, model);
		btn6.registerAlphaFunction(R.drawable.keyf6, "f");
		btn6.registerFirstFunction(R.drawable.key6f, "6");
		model.mView.registerAlphaButton(btn6);
		addView(btn6, 
    			new AbsoluteLayout.LayoutParams(btn6.WIDTH, btn6.HEIGHT, x, y)
    	);
		y = y + btn6.HEIGHT;

		x = 0;
		ButtonKeyAlpha btn1 = new ButtonKeyAlpha(context, model);
		btn1.registerAlphaFunction(R.drawable.keya1, "a");
		btn1.registerFirstFunction(R.drawable.key1a, "1");
		model.mView.registerAlphaButton(btn1);
		addView(btn1, 
    			new AbsoluteLayout.LayoutParams(btn1.WIDTH, btn1.HEIGHT, x, y)
    	);
		x = x + btn1.WIDTH;

		ButtonKeyAlpha btn2 = new ButtonKeyAlpha(context, model);
		btn2.registerAlphaFunction(R.drawable.keyb2, "b");
		btn2.registerFirstFunction(R.drawable.key2b, "2");
		model.mView.registerAlphaButton(btn2);
		addView(btn2, 
    			new AbsoluteLayout.LayoutParams(btn2.WIDTH, btn2.HEIGHT, x, y)
    	);
		x = x + btn2.WIDTH;

		ButtonKeyAlpha btn3 = new ButtonKeyAlpha(context, model);
		btn3.registerAlphaFunction(R.drawable.keyc3, "c");
		btn3.registerFirstFunction(R.drawable.key3c, "3");
		model.mView.registerAlphaButton(btn3);
		addView(btn3, 
    			new AbsoluteLayout.LayoutParams(btn3.WIDTH, btn3.HEIGHT, x, y)
    	);
		y = y + btn3.HEIGHT;

		x = 0;
		ButtonKey btn0 = new ButtonKey(context, model, "0");
		addView(btn0, 
    			new AbsoluteLayout.LayoutParams(btn0.WIDTH, btn0.HEIGHT, x, y)
    	);
		x = x + btn0.WIDTH;

		ButtonKey btnDecimailPoint = new ButtonKey(context, model, ".");
		addView(btnDecimailPoint, 
    			new AbsoluteLayout.LayoutParams(btnDecimailPoint.WIDTH, btnDecimailPoint.HEIGHT, x, y)
    	);
		x = x + btnDecimailPoint.WIDTH;

		ButtonKey btnSpace = new ButtonKey(context, model, "spc");
		btnSpace.setKey(" ");
		btnSpace.setTextSize((float) 0.6 * btnSpace.HEIGHT);
		addView(btnSpace, 
    			new AbsoluteLayout.LayoutParams(btnSpace.WIDTH, btnSpace.HEIGHT, x, y)
    	);
		x = x + btnSpace.WIDTH;
		y = y + btnSpace.HEIGHT;

		WIDTH = x;
		HEIGHT = y;
	}
	
	

}
